﻿<Controls:MetroWindow x:Class="RazorSourceGenerator.SchemaInfoView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
        Title="SchemaInfo" Height="360" Width="660" WindowStartupLocation="CenterOwner">
  <Window.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="CommonStyle.xaml" />
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
  </Window.Resources>
  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="10" ></RowDefinition>
      <RowDefinition Height="*" ></RowDefinition>
      <RowDefinition Height="50" ></RowDefinition>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width=".20*"></ColumnDefinition>
      <ColumnDefinition Width=".80*"></ColumnDefinition>
    </Grid.ColumnDefinitions>
    <Controls:ProgressRing Grid.Row="1" Grid.Column="1" Grid.ZIndex="1" IsActive="{Binding SelectedTableSchema.IsLoading}"/>
    <ListView Margin="10 0 0 0" Grid.Column="0" Grid.Row="1" ItemsSource="{Binding TableSchemas}" 
                  SelectionMode="Single" BorderThickness="0" SelectedItem="{Binding SelectedTableSchema, Mode=TwoWay}">
      <ListView.ItemTemplate>
        <DataTemplate>
          <Grid>
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="*" />
              <ColumnDefinition Width="22" />
            </Grid.ColumnDefinitions>
            <StackPanel Grid.Row="0" Grid.Column="0" Margin="5 0 0 0" Orientation="Horizontal" Height="30">
              <CheckBox IsChecked="{Binding IsChecked, Mode=TwoWay}" VerticalAlignment="Center"/>
              <TextBlock Text="{Binding TableName}" VerticalAlignment="Center"></TextBlock>
            </StackPanel>
            <Grid.Triggers>
              <EventTrigger RoutedEvent="GotFocus">
                <BeginStoryboard>
                  <Storyboard>
                    <BooleanAnimationUsingKeyFrames Duration="00:00:00" Storyboard.Target="{Binding Path=., RelativeSource={RelativeSource FindAncestor, AncestorType=ListBoxItem}}" Storyboard.TargetProperty="IsSelected">
                      <DiscreteBooleanKeyFrame Value="True" />
                    </BooleanAnimationUsingKeyFrames>
                  </Storyboard>
                </BeginStoryboard>
              </EventTrigger>
            </Grid.Triggers>
          </Grid>
        </DataTemplate>
      </ListView.ItemTemplate>
    </ListView>
    <GridSplitter Width="2" Grid.Row="1"/>
    <DataGrid Grid.Column="1" Grid.Row="1"  Margin="0 0 10 0" AutoGenerateColumns="True" IsReadOnly="True" 
                  Style="{StaticResource MetroDataGridStyle}" ItemsSource="{Binding SelectedTableSchema.TableSchema}" ></DataGrid>
    <DockPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2">
      <Button Content="OK" Height="23" Width="75" Margin="10 0 0 0" Name="btnOK" DockPanel.Dock="Left" Click="btnOK_Click" />
      <Button Content="Cancel" Height="23" Width="75"  Margin="0 0 10 0" Name="btnCancel" DockPanel.Dock="Right" HorizontalAlignment="Right" Click="btnCancel_Click"/>
    </DockPanel>
  </Grid>
</Controls:MetroWindow>
